package com.bifrost.wechat.service;

import com.bifrost.wechat.event.OauthCompleteEvent;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

@Service
public class Oauth2Service implements ApplicationContextAware {
    protected ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext=applicationContext;
    }
   public void publishEvent(WxMpUser user,String appid){

       OauthCompleteEvent event = new OauthCompleteEvent(user,appid);
       this.applicationContext.publishEvent(event);
    }
}
